from .base import BaseModel

class Owner(BaseModel):
    """单位模型"""
    
    def __init__(self):
        super().__init__()
        self.owner_id = None  # 单位ID
        self.owner_name = None  # 单位名称
        self.create_time = None  # 创建时间
        self.update_time = None  # 更新时间
    
    def __str__(self):
        return f"Owner(id={self.owner_id}, name={self.owner_name})"
    
    def to_dict(self):
        """将模型转换为字典格式"""
        return {
            'owner_id': self.owner_id,
            'owner_name': self.owner_name,
            'create_time': self.create_time.strftime('%Y-%m-%d %H:%M:%S') if self.create_time else None,
            'update_time': self.update_time.strftime('%Y-%m-%d %H:%M:%S') if self.update_time else None
        }

class OwnerRelation(BaseModel):
    """单位关系模型"""
    
    def __init__(self):
        super().__init__()
        self.parent_id = None  # 父单位ID
        self.child_id = None  # 子单位ID
        self.parent_type = None  # 父单位类型
        self.child_type = None  # 子单位类型
        self.create_time = None  # 创建时间
        self.update_time = None  # 更新时间
    
    def __str__(self):
        return f"OwnerRelation(parent={self.parent_id}, child={self.child_id}, type={self.parent_type}/{self.child_type})"